import { legacy_createStore, combineReducers, compose, applyMiddleware } from "redux";
import { thunk } from 'redux-thunk' 

// 引入reducer
import numReducer from './NumStatus/reducer.ts'
import arrReducer from './ArrStatus/reducer.ts'

// 汇总多个reducer
const allReducer = combineReducers({
    numReducer,
    arrReducer
})


// 创建数据仓库
// window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 为了让浏览器正常使用redux-dev-tools插件
// export default legacy_createStore(allReducer,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())


// 判断有没有__REDUX_DEVTOOLS_EXTENSION_COMPOSE__这个模块。兼容异步
let composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose //rt

// 把仓库数据，浏览器redux-dev-tools，还有reduxThunk插件关联在store中
const store = legacy_createStore(allReducer, composeEnhancers(applyMiddleware(thunk)));
export default store